{extend name="admin@index_layout"/}
{block name="main"}
<div class="layui-card">
    <div class="layui-card-header">会员卡订单管理</div>
    <div class="layui-card-body">
        <table class="layui-hide" id="currentTable" lay-filter="currentTable"
               data-auth-add="{:$auth->check('vip.viporder/add')}"
               data-auth-edit="{:$auth->check('vip.viporder/edit')}"
               data-auth-delete="{:$auth->check('vip.viporder/del')}"
        ></table>
    </div>
</div>
<script type="text/html" id="picTpl">
    <img style="max-width:80px; max-height:30px;" src="{{d.avatarUrl}}" data-image="{{d.nickname}}">
</script>
<script type="text/html" id="picTpl2">
    <img style="max-width:80px; max-height:30px;" src="{{d.package_img}}" data-image="{{d.package_name}}">
</script>

<script type="text/html" id="barTool">
<!--    <a data-open='{:url("detail")}?id={{ d.id }}'-->
<!--       class="layui-btn layui-btn-xs {:$auth->check('vip.viporder/detail')?'':'layui-hide'}"-->
<!--       title="陪诊卡详细">会员卡详细</a>-->
    {{# if(d.status==2){ }}
    <a data-open='{:url("refund")}?id={{ d.id }}'
       class="layui-btn layui-btn-xs layui-btn-danger {:$auth->check('vip.viporder/refund')?'':'layui-hide'}"
       title="查看订单">后台退款</a>
    {{# } }}
</script>


<!--操作模板-->

{/block}
{block name="script"}
<script>
    var selectElement = null;
    layui.use('yznTable', function () {
        var table = layui.yznTable;

        var init = {
            table_elem: '#currentTable',
            table_render_id: 'currentTable',
            add_url: "{:url('add')}",
            edit_url: "{:url('edit')}",
            delete_url: "{:url('del')}",
        };
        var package_list = {:json_encode($package_list)};
        table.render({
            init: init,
            autoWidth: true,
            toolbar: ['refresh',],
            url: '{:url("index")}',
            cols: [
                [
                    //预约时间 是否分派 陪诊服务 陪诊人员 会员折扣 优惠卷金额
                    // {type: 'checkbox', fixed: 'left'},
                    {field: 'id', width: '4%', title: 'ID',search:false},
                    {field: 'order_no', align: "center", width: '18%', title: '订单编号'},
                    {field: 'mc_name', align: "center", width: '12%', title: '会员卡名称',search:false},
                    {field: 'nickname', align: "center", width: '10%', title: '下单会员'},
                    {field: 'mobile', align: "center", width: '10%', title: '会员电话',search:false},
                    {field: 'avatarUrl', align: "center", width: '10%', title: '用户头像', templet: '#picTpl',search:false},
                    {
                        //订单状态 1待支付2待指派3服务中4已完成5已取消6已退款7已指派8已评价
                        field: 'status', align: "center", width: '10%', title: '订单状态', templet: function (d) {
                              if (d.status == 2) {
                                return '<span style="color:  #00B7EE ">已完成</span>';
                            } else if (d.status == 3) {
                                return '<span style="color: #0000FF">已退款</span>';
                            }  else if (d.status == 1) {
                                  return '<span style="color: red">待支付</span>';
                              } else if (d.status == 4) {
                                  return '<span style="color: #c0ccda">已取消</span>';
                              }
                        }, selectList: {1:'待支付',2:'已完成',3:'已退款',4:'已取消'}
                    },
                    {field: 'create_time', align: "center", width: '15%', title: '下单时间', search: 'range'},
                    {field: 'pay_money', align: "center", width: '10%', title: '支付金额',search:false},
                    {field: 'pay_time', align: "center", width: '15%', title: '支付时间', search: 'range'},
                    { fixed: 'right',align: 'center',width: '10%', title: '操作',toolbar: '#barTool' }//delete'
                ]
            ],
            page: {}
        });
        yznTable.bindevent();
    });
</script>
{/block}